{extend name="common/base"}
{block name='title'}用户编辑页面{/block}
{block name='body-type'}user_edit{/block}
{block name="content"}
        <!-- 内容区域 -->
        <div class="tpl-content-wrapper">

            <div class="row-content am-cf">


                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">编辑用户</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form enctype="multipart/form-data" class="am-form tpl-form-border-form tpl-form-border-br" action="{:Url('admin/user/update')}?id={$result.id}" method="post">
                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">用户名<span class="tpl-form-line-small-title">name</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" name="name" class="tpl-form-input" id="user-name" placeholder="请输入排列顺序" value="{$result.name}">
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-name" class="am-u-sm-3 am-form-label">性别<span class="tpl-form-line-small-title">sex</span></label>
                                        <div class="am-u-sm-9">
                                            <select name="sex" id="">
                                                <option value="1" {if condition="$result['sex']==1"}selected {/if}>男</option>
                                                <option value="2" {if condition="$result['sex']==2"}selected {/if}>女</option>
                                                <option value="0" {if condition="$result['sex']==0"}selected {/if}>未知</option>
                                            </select>
                                            <!-- <input type="text" name="sex" class="tpl-form-input" id="user-name" placeholder="请输入排列顺序" value="{$result.sex}"> -->
                                        </div>
                                    </div>
                                    
                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">电话<span class="tpl-form-line-small-title">Tell</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" id="tell" placeholder="" name="tell" value="{$result.tell}" readonly='readonly'>
                                            <div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">余额<span class="tpl-form-line-small-title">Tell</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" id="tell" placeholder="" name="money" value="¥{$result.money}" readonly='readonly'>
                                            <div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">注册时间<span class="tpl-form-line-small-title">Date</span></label>
                                        <div class="am-u-sm-9">
                                            <input type="text" id="tell" placeholder="" name="date" value="{$result.date}" readonly='readonly'>
                                            <div>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="am-form-group">
                                        <label for="user-weibo" class="am-u-sm-3 am-form-label">头像 <span class="tpl-form-line-small-title">Images</span></label>
                                        <div class="am-u-sm-9">
                                            <div class="am-form-group am-form-file">
                                                <!-- <div class="tpl-form-file-img">
                                                    <img src="__STATIC__/admin/assets/img/a5.png" alt="">
                                                </div> -->
                                                <button type="button" class="am-btn am-btn-danger am-btn-sm">
                                                <i class="am-icon-cloud-upload"></i>更新头像</button>
                                                <input id="doc-form-file" type="file" multiple="" name="headimg_url" onchange="upimg(this)"><br>
                                                <img src="{$result.headimg_url}" alt="" id="img-view-box" width="150">
                                                <input type="hidden" id="img-value-box" name="headimg_url">
                                            </div>

                                        </div>
                                    </div>



                                    <div class="am-form-group">
                                        <div class="am-u-sm-9 am-u-sm-push-3">
                                            <button type="submit" class="am-btn am-btn-primary tpl-btn-bg-color-success ">提交</button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>



            </div>
        </div>
        {/block}
        {block name="footer-js"}
        <script>
            function upimg(obj)
          {
            if( obj.value == "" ) {
              return;
            }
            var formdata = new FormData(); 
            formdata.append("headimg_url" , $(obj)[0].files[0]);//获取文件法二
            $.ajax({
              type : 'post',
              url : "{:Url('admin/user/upimg')}",
              data : formdata,
              cache : false,
              processData : false, // 不处理发送的数据，因为data值是Formdata对象，不需要对数据做处理
              contentType : false, // 不设置Content-type请求头
              success : function(ret){
                $('#img-view-box').attr('src', ret.headimg_url);
                $('#img-value-box').val(ret.headimg_url);
                $('#thumb-img-value-box').val(ret.thumb_headimg_url);

                  //alert(obj.value);
              },
              error : function(){ }
            });
          }   
        </script>
        {/block}